#!/bin/bash

# 真实游戏场景测试执行脚本（从项目根目录执行）
# 用法：
#   ./run_real_game_test.sh dev   # 开发环境(127.0.0.1)
#   ./run_real_game_test.sh test  # 测试环境(47.106.214.252)

ENV=${1:-dev}

echo "========================================="
echo "真实游戏场景测试"
echo "========================================="
echo "环境: $ENV"

if [ "$ENV" = "dev" ]; then
    echo "服务器: 127.0.0.1:8889"
elif [ "$ENV" = "test" ]; then
    echo "服务器: 47.106.214.252:8889"
else
    echo "❌ 错误：环境参数必须是 dev 或 test"
    echo "用法：./run_real_game_test.sh [dev|test]"
    exit 1
fi

echo "========================================="
echo ""

# 确保在项目根目录
cd "$(dirname "$0")" || exit

# 执行测试（指定模块）
# 注意：旧测试文件已重命名为.bak避免编译错误
mvn test -pl pokermind-serv-dse-tcp \
  -Dtest=RealGameScenarioExecutableTest \
  -Denv="$ENV"

TEST_RESULT=$?

echo ""
echo "========================================="
if [ $TEST_RESULT -eq 0 ]; then
    echo "✅ 测试成功!"
else
    echo "❌ 测试失败! 退出码: $TEST_RESULT"
fi
echo "========================================="

exit $TEST_RESULT

